package com.foreknow.demo12;

import java.awt.*;
import java.util.Date;
import java.util.LinkedList;

public class LinkedListDemo {
    public static void main(String[] args) {
        LinkedList<Object> list = new LinkedList<>();
        list.push("哈哈");
        list.push("洗洗");
        list.push(100);
        list.push(3.14);
        list.push(new Date());
        for (int i = 0; i < list.size(); i++) {
            Object o = list.get(i);
            System.out.println(o);
        }
        System.out.println("-----------------");

        Object x = list.peek();//检查但不删除此列表的头（第一个元素），查看顶部
        System.out.println(x);

        System.out.println("-----------------");
        for (int i = 0; i < list.size(); i++) {
            Object o = list.get(i);
            System.out.println(o);
        }
        System.out.println("-----------------");
        Object y = list.pop();//从列表表示的堆栈中弹出一个元素
        System.out.println(y);
    }
}
